Deliverable 1
Generalising the Traditional Wiki Systems to New Media Page Formats
Purpose:
To add a clever direct messaging system to web portal like Yioop. The motive behind this deliverable is to setup a pre-defined group that will enable direct messaging between users of Yioop.
Description:
Yioop follows the model-view-controller (MVC) software design pattern, so the models that create/edit users and groups in Yioop were used to add said pre-defined groups called "Chats" though the "accountaccescomponent" controller.
Code Snippet from controller when creating New Users:
case "adduser":
if ($pass_len > C\LONG_NAME_LEN ) {
return $parent->redirectWithMessage(
tl('accountaccess_component_passwords_too_long'),
$request_fields);
} else if ($_REQUEST['retypepassword'] !=
$_REQUEST['password']) {
return $parent->redirectWithMessage(
tl('accountaccess_component_passwords_dont_match'),
$request_fields);
} else if (trim($username) == "") {
return $parent->redirectWithMessage(
tl('accountaccess_component_invalid_username'),
$request_fields);
} else if ($signin_model->getUserId($username) > 0) {
return $parent->redirectWithMessage(
tl('accountaccess_component_user_exists'),
$request_fields);
} else if (!isset($data['STATUS_CODES'][$_REQUEST['status']])) {
$_REQUEST['status'] = C\INACTIVE_STATUS;
} else {
$norm_password = "";
$norm_password = substr($parent->clean($_REQUEST['password'],
"string"), 0, C\LONG_NAME_LEN);
$username = trim($username);
$uid = $user_model->addUser($username, $norm_password,
substr(trim($parent->clean($_REQUEST['first_name'],
"string")), 0, C\NAME_LEN),
substr(trim($parent->clean($_REQUEST['last_name'],
"string")), 0, C\NAME_LEN),
substr(trim($parent->clean($_REQUEST['email'],
"string")), 0, C\LONG_NAME_LEN),
$_REQUEST['status']);
$data['USER_NAMES'][$username] = $username;
//personal chats group for new users
$username = strtolower($username);
$grpNameWId = 'Chats$'.$username.'$'.$uid;
if ($uid == C\PUBLIC_USER_ID) {
return $parent->redirectWithMessage(
tl('social_component_public_cant_create'));
} else if ($group_model->getGroupId($grpNameWId) > 0) {
return $parent->redirectWithMessage(
tl('social_component_groupname_exists'));
} else {
$group_fields = ["member_access" => ["ACCESS_CODES", C\ACTIVE_STATUS],
"register" => ["REGISTER_CODES", C\NO_JOIN],
"vote_access" => ["VOTING_CODES",C\NON_VOTING_GROUP],
"post_lifetime" => ["POST_LIFETIMES", C\FOREVER],
"encryption" => ["ENCRYPTION_CODES", 0]];
foreach ($group_fields as $field => $info) {
if (!isset($_REQUEST[$field]) ||
!in_array($_REQUEST[$field],
array_keys($data[$info[0]]))) {
$_REQUEST[$field] = $info[1];
}
}
$group_model->addGroup($grpNameWId,
$uid, $_REQUEST['register'],
$_REQUEST['member_access'],
$_REQUEST['vote_access'],
$_REQUEST['post_lifetime'],
$_REQUEST['encryption']);
//one exception to setting $group_id
$group_id = $group_model->getGroupId($grpNameWId);
}
return $parent->redirectWithMessage(
tl('accountaccess_component_user_added'),
$request_fields);
}
break;
Sample Output:
Creating a new user:
Pre-defined "Chats" group created for new user:
|