function display($save = '', $pt = 0) { //trigger event $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeProfileTypeSelection'); // check for session // if does not exist redirect user to community page XiptHelperProfiletypes::checkSessionForProfileType(); //If not allowed to select PT for user then return if (XiptFactory::getSettings('show_ptype_during_reg') == 0) { $selectedProfiletypeID = XiptLibProfiletypes::getDefaultProfiletype(); XiptHelperProfiletypes::setProfileTypeInSession($selectedProfiletypeID); } // do some validation for visibility and publish of ptype if (JRequest::getVar('save', $save, 'POST') != '') { $selectedProfiletypeID = JRequest::getVar('profiletypes', $pt, 'POST'); if (XiptLibProfiletypes::validateProfiletype($selectedProfiletypeID, array('published' => 1, 'visible' => 1)) == false) { $msg = XiptText::_('INVALID_PROFILE_TYPE_SELECTED'); $link = XiptRoute::_('index.php?option=com_xipt&view=registration', false); $this->setRedirect($link, $msg); } $dispatcher->trigger('onAfterProfileTypeSelection', array(&$selectedProfiletypeID)); return true; } // Get the view $this->getView()->display(); }
function getFieldHTML($field, $required) { // it might be some other user (in case of admin is editing profile) $user =& JFactory::getUser(); $tName = $field->value; $templates = XiptHelperJomsocial::getTemplatesList(); $class = $required == 1 ? ' required' : ''; $selectedValue = $this->getTemplateValue($tName, $user->id); // XITODO : format it in proper way $allowToChangeTemplate = XiptHelperProfiletypes::getProfileTypeData(XiptLibProfiletypes::getUserData($user->id), 'allowt'); $allowToChangeTemplate = $allowToChangeTemplate || XiptHelperUtils::isAdmin($user->id); if (!$allowToChangeTemplate) { $html = '<input type="hidden" id="field' . $field->id . '" name="field' . $field->id . '" value="' . $selectedValue . '" />'; $html .= $selectedValue; return $html; } $html = '<select id="field' . $field->id . '" name="field' . $field->id . '" class="hasTip select' . $class . ' inputbox" title="' . $field->name . '::' . htmlentities($field->tips) . '">'; $selectedElement = 0; if (!empty($templates)) { foreach ($templates as $tmpl) { $selected = $tmpl == $selectedValue ? ' selected="selected"' : ''; if (!empty($selected)) { $selectedElement++; } $html .= '<option value="' . $tmpl . '"' . $selected . '>' . $tmpl . '</option>'; } } $html .= '</select>'; $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;"> </span>'; return $html; }
function save($post = null) { if ($post === null) { $post = JRequest::get('post'); } $menuid = isset($post['id']) ? $post['id'] : 0; $otherMenuid = isset($post['menuIds']) ? $post['menuIds'] : array(); $menuPtype = isset($post['profileTypes']) ? $post['profileTypes'] : array(); $allTypes = XiptHelperProfiletypes::getProfileTypeArray(); $model = $this->getModel(); // menuid is also selected in otherMenuid then no need to add if (!in_array($menuid, $otherMenuid)) { array_push($otherMenuid, $menuid); } //remove all rows related to specific menu id foreach ($otherMenuid as $id) { $model->delete(array('menuid' => $id)); } $msg = XiptText::_('MENU_SAVED'); $link = XiptRoute::_('index.php?option=com_xipt&view=jstoolbar', false); $this->setRedirect($link, $msg); //if all selected, return true if (array_diff($allTypes, $menuPtype) == array()) { return true; } $ptypesToChange = array_diff($allTypes, $menuPtype); foreach ($ptypesToChange as $type) { foreach ($otherMenuid as $id) { if ($this->getModel()->save(array('menuid' => $id, 'profiletype' => $type)) == false) { return false; } } } return true; }
function isApplicable() { $ptypes = XiptHelperProfiletypes::getProfileTypeArray(); if ($ptypes) { return true; } return false; }
function isRequired() { $ptypes = XiptHelperProfiletypes::getProfileTypeArray(); if ($ptypes) { return false; } return true; }
function isRequired() { $ptypeArray = XiptHelperProfiletypes::getProfileTypeArray(); $globalWM = XiptFactory::getSettings('show_watermark', 0); if ($globalWM) { return false; } foreach ($ptypeArray as $ptype) { $watermarkParams = XiptLibProfiletypes::getParams($ptype, 'watermarkparams'); if ($watermarkParams->get('enableWaterMark', 0) == true) { return true; } } return false; }
function buildProfileTypesforJSToolbar($menuid) { $selectedTypes = self::getProfileTypeArray($menuid); $allTypes = XiptHelperProfiletypes::getProfileTypeArray(); $html = ''; $html .= '<span>'; foreach ($allTypes as $option) { // XITODO : improve following condition $selected = in_array($option, $selectedTypes) || in_array(XIPT_PROFILETYPE_ALL, $selectedTypes) ? ' checked="checked"' : ''; $html .= '<lable><input type="checkbox" id="profileTypes' . $option . '" name="profileTypes[]" value="' . $option . '"' . $selected . '" style="margin: 0 5px 5px 0;" />'; $html .= XiptHelperProfiletypes::getProfileTypeName($option) . '</lable>'; $html .= '<div class="clr"></div>'; } $html .= '</span>'; return $html; }
function buildProfileTypes($fid, $for) { $selectedTypes = XiptHelperProfilefields::getProfileTypeArray($fid, $for); $allTypes = XiptHelperProfiletypes::getProfileTypeArray(); $html = ''; $categories = XiptHelperProfilefields::getProfileFieldCategories(); $name = $categories[$for]['controlName']; $html .= '<span>'; foreach ($allTypes as $option) { $selected = in_array($option, $selectedTypes) || in_array(XIPT_PROFILETYPE_ALL, $selectedTypes) ? ' checked="checked"' : ''; $html .= '<lable><input type="checkbox" name= "' . $name . '[]" value="' . $option . '" ' . $selected . ' " style="margin: 0 5px 5px 0;" />'; $html .= XiptHelperProfiletypes::getProfileTypeName($option) . '</lable>'; $html .= '<div class="clr"></div>'; } $html .= '</span>'; return $html; }
function buildProfileTypes($name, $value, $control_name, $fid) { $allTypes = XiptHelperProfiletypes::getProfileTypeArray(true, true); $html = ''; $html .= '<select id="' . $control_name . '[' . $name . '][' . $fid . '][]" name="' . $control_name . '[' . $name . '][' . $fid . '][]" value="" style="margin: 0 5px 5px 0;" size="3" multiple/>'; foreach ($allTypes as $option) { $ptypeName = XiptHelperProfiletypes::getProfileTypeName($option); $selected = ''; if (is_array($value) && array_key_exists($fid, $value) && in_array($option, $value[$fid])) { $selected = 'SELECTED'; } $html .= '<option name="' . $name . '_' . $option . '" "' . $selected . '" value="' . $option . '">'; $html .= XiptHelperProfiletypes::getProfileTypeName($option) . '</option>'; } $html .= '</select>'; return $html; }
function save($post = null) { if ($post === null) { $post = JRequest::get('post'); } $fid = isset($post['id']) ? $post['id'] : 0; $otherFids = isset($post['fieldIds']) ? $post['fieldIds'] : array(); $allTypes = XiptHelperProfiletypes::getProfileTypeArray(); $fieldModel = $this->getModel(); // fid is also selected in otherAid then no need to add if (!in_array($fid, $otherFids)) { array_push($otherFids, $fid); } //remove all rows related to specific field id // cleaning all data for storing new profiletype with fields foreach ($otherFids as $id) { $fieldModel->delete(array('fid' => $id)); } $categories = XiptHelperProfilefields::getProfileFieldCategories(); // for each category foreach ($categories as $catIndex => $catInfo) { $controlName = $catInfo['controlName']; $selectedPtypes = isset($post[$controlName]) ? $post[$controlName] : array(); // if all profile types are selected $ptypesToChange = array_diff($allTypes, $selectedPtypes); if ($ptypesToChange == array()) { continue; } // for each profile type foreach ($ptypesToChange as $type) { foreach ($otherFids as $id) { if ($this->getModel()->save(array('fid' => $id, 'pid' => $type, 'category' => $catIndex)) == false) { return false; } } } } $msg = XiptText::_('FIELDS_SAVED'); $link = XiptRoute::_('index.php?option=com_xipt&view=profilefields', false); $this->setRedirect($link, $msg); return true; }
function display($tpl = null) { $aclModel = $this->getModel(); $pagination = $aclModel->getPagination(); $rules = $aclModel->loadRecords($pagination->limit, $pagination->limitstart); $this->setToolbar(); $ruleProfiletype = array(); if (!empty($rules)) { foreach ($rules as $rule) { $aclObject = XiptAclFactory::getAclObject($rule->aclname); $aclObject->bind($rule); $ptype = $aclObject->getCoreParams('core_profiletype', 0); $ruleProfiletype[$rule->id] = XiptHelperProfiletypes::getProfiletypeName($ptype, true); } } $this->assign('rules', $rules); $this->assign('ruleProfiletype', $ruleProfiletype); $this->assignRef('pagination', $pagination); return parent::display($tpl); }
function isApplicable() { $plugin = XiptHelperUtils::getPluginStatus('xi_adminapproval'); if (XIPT_JOOMLA_15) { if ($plugin && $plugin->published == 1) { return false; } } else { if ($plugin && $plugin->enabled == 1) { return false; } } $ptypeArray = XiptHelperProfiletypes::getProfileTypeArray(); foreach ($ptypeArray as $ptype) { if (XiptHelperProfiletypes::getProfileTypeData($ptype, 'approve') == true) { return true; } } return false; }
function fetchElement($name, $value, &$node, $control_name) { /*value contain profiletype id so get watermark from function */ $watermark = XiptHelperProfiletypes::getProfileTypeData($value, 'watermark'); $generatedImage = ''; /*generate image from watermark */ $imagePath = JPATH_ROOT . DS . DEFAULT_DEMOAVATAR; $watermarkPath = JPATH_ROOT . DS . $watermark; $watermarkParams = XiptLibProfiletypes::getParams($value, 'watermarkparams'); if (JFile::exists($imagePath) && JFile::exists($watermarkPath)) { $generatedImage = XiptHelperImage::showWatermarkOverImage($imagePath, $watermarkPath, 'ptype_' . $value, $watermarkParams->get('xiWatermarkPosition')); } if (DS == '\\') { $generatedImage = str_replace('\\', '/', $generatedImage); } $html = ''; if ($generatedImage == false || $generatedImage == '') { $generatedImage = DEFAULT_DEMOAVATAR; } $html .= '<img src="' . JURI::root() . '/' . $generatedImage . '" width="64" height="64" alt="generatedimage" border=10 />'; return $html; }
function showActivity($userid, $newPtype, $oldPtype) { if ($newPtype === $oldPtype) { return; } $ptName = XiptHelperProfiletypes::getProfileTypeData($newPtype, 'name'); $act = new stdClass(); $act->cmd = 'wall.write'; $act->actor = $userid; $act->target = 0; // no target $changePt = XiptText::_('CHANGED_PROFILETYPE_TO'); $act->title = JText::_('{actor}' . $changePt . $ptName); $act->content = ''; $act->app = 'wall'; $act->cid = 0; CFactory::load('libraries', 'activities'); $act->comment_type = 'xipt_community.myaction'; $act->comment_id = CActivities::COMMENT_SELF; $act->like_type = 'xipt_community.myaction'; $act->like_id = CActivities::LIKE_SELF; CActivityStream::add($act); return true; }
function getProfiletypeData($id = 0, $what = 'name') { $val = XiptHelperProfiletypes::getProfileTypeData($id, $what); return $val; }
function getProfileTypeName($id) { //XITODO : Clean ALL / NONE, and cache results if ($id == XIPT_PROFILETYPE_ALL || empty($id)) { return XiptText::_("ALL"); } if ($id == XIPT_PROFILETYPE_NONE) { return XiptText::_("NONE"); } return XiptHelperProfiletypes::getProfileTypeData($id, 'name'); }
function onAfterProfileTypeSelection($ptypeid) { // set the profile type in session return XiptHelperProfiletypes::setProfileTypeInSession($ptypeid); }
<div class="elementParams"> <div class="paramTitle"> <label class="hasTip" title="<?php echo XiptText::_('SELECT_DEFAULT_GROUP_TO_ASSIGN'); ?> ::<?php echo XiptText::_('SELECT_DEFAULT_GROUP_TO_ASSIGN_DESC'); ?> "> <?php echo XiptText::_('SELECT_DEFAULT_GROUP_TO_ASSIGN'); ?> </label> </div> <div class="paramValue"><?php echo XiptHelperProfiletypes::buildTypes($this->data->group, 'group', true); ?> </div> </div> <?php echo $this->pane->endPanel(); echo $this->pane->startPanel(XiptText::_('PRIVACY_SETTINGS'), 'xiprivacysettings-page'); echo $this->privacyParams->render('privacy'); echo $this->pane->endPanel(); echo $this->pane->startPanel(XiptText::_('REGISTRATION'), 'xiconfiguration-page'); echo $this->configParams->render('config'); echo $this->pane->endPanel(); echo $this->pane->startPanel(XiptText::_('WATERMARK'), 'watermark-page'); echo $this->watermarkParams->render('watermarkparams'); echo $this->pane->endPanel();
function _processSave($post = null, $id = 0) { if ($post === null) { $post = JRequest::get('post'); } $id = JRequest::getVar('id', $id, 'post'); //We only need few data as special case $data = $post; $data['tip'] = JRequest::getVar('tip', $post['tip'], 'post', 'string', JREQUEST_ALLOWRAW); $data['group'] = implode(',', $post['group']); // These data will be seperately stored, we dont want to update these unset($data['watermarkparams']); unset($data['config']); unset($data['privacy']); $model = $this->getModel(); //for Reset we will save old Data // give 0 in loadRecords so that all records will be loaded $allData = $model->loadRecords(0); if (isset($allData[$id])) { $oldData = $allData[$id]; } // set ordering if (end($allData)) { if ($allData[$id]->id == 0) { $data['ordering'] = end($allData)->ordering + 1; } } else { $data['ordering'] = 1; } // now save model $id = $model->save($data, $id); XiptError::assert($id, XiptText::_("{$id} NOT_EXISTS"), XiptError::ERROR); // Now store other data // Handle Avatar : call uploadImage function if post(image) data is set $fileAvatar = JRequest::getVar('FileAvatar', '', 'FILES', 'array'); if (isset($fileAvatar['tmp_name']) && !empty($fileAvatar['tmp_name'])) { XiptHelperProfiletypes::uploadAndSetImage($fileAvatar, $id, 'avatar'); } //display demo on watermark profile according ProfileType if ($post['watermarkparams']['enableWaterMark']) { $post['watermarkparams']['demo'] = $id; } // if jsPrivacyController = 0 then Old privacy set in profile-type table if (is_array($post['privacy']) && $post['privacy']['jsPrivacyController'] == 0) { $oldPrivacy = $model->loadParams($id, 'privacy')->toArray(); $oldPrivacy['jsPrivacyController'] = $post['privacy']['jsPrivacyController']; $post['privacy'] = $oldPrivacy; } // Handle Params : watermarkparams, privacy, config $model->saveParams($post['watermarkparams'], $id, 'watermarkparams'); $model->saveParams($post['config'], $id, 'config'); $model->saveParams($post['privacy'], $id, 'privacy'); // now generate watermark, and update watermark field $image = $this->_saveWatermark($id); //XITODO : Ensure data is reloaded, not cached $newData = $model->loadRecords(0); $newData = $newData[$id]; //to reset privacy of users need to load from loadParams $newData->privacy = $model->loadParams($id, 'privacy'); // Reset existing user's if ($post['resetAll'] && isset($oldData)) { $newData = serialize($newData); //new method $preTask = JRequest::getVar('task', 'save'); $session = JFactory::getSession(); $session->set('oldPtData', $oldData, 'jspt'); $session->set('newPtData', $newData, 'jspt'); $session->set('preTask', $preTask, 'jspt'); if (!XIPT_TEST_MODE) { JFactory::getApplication()->redirect(XiPTRoute::_("index.php?option=com_xipt&view=profiletypes&task=resetall&id={$id}", false)); } $this->resetall($id, 25000); //old method //XiptHelperProfiletypes::resetAllUsers($id, $oldData, $newData); } $info['id'] = $id; $info['msg'] = XiptText::_('PROFILETYPE_SAVED'); return $info; }