Пример #1
0
 function getFieldsForProfiletype(&$fields, $selectedProfiletypeID, $from, $notSelectedFields = null)
 {
     XiptError::assert($selectedProfiletypeID, XiptText::_("SELECTED_PROFILETYPE_DOES_NOT_EXIST"), XiptError::ERROR);
     $task = JRequest::getVar('task', '');
     if ($notSelectedFields === null) {
         $categories = XiptHelperProfilefields::getProfileFieldCategories();
         foreach ($categories as $catIndex => $catInfo) {
             $catName = $catInfo['name'];
             $notSelectedFields[$catName] = $this->getNotSelectedFieldForProfiletype($selectedProfiletypeID, $catIndex);
         }
     }
     $count = count($fields);
     for ($i = 0; $i < $count; $i++) {
         $field =& $fields[$i];
         if (is_object($field)) {
             $fieldId = $field->id;
         } else {
             $fieldId = $field['id'];
         }
         if (in_array($fieldId, $notSelectedFields['ALLOWED'])) {
             unset($fields[$i]);
             continue;
         }
         if (in_array($fieldId, $notSelectedFields['REQUIRED'])) {
             if (is_object($field)) {
                 $field->required = 0;
             } else {
                 $field['required'] = 0;
             }
         }
         if (in_array($fieldId, $notSelectedFields['VISIBLE']) && $from === 'getViewableProfile') {
             unset($fields[$i]);
             continue;
         }
         if (in_array($fieldId, $notSelectedFields['EDITABLE_AFTER_REG']) && $from === 'getEditableProfile' && JFactory::getApplication()->isAdmin() == false) {
             unset($fields[$i]);
             continue;
         }
         if (in_array($fieldId, $notSelectedFields['EDITABLE_DURING_REG']) && $from != 'getViewableProfile' && $from != 'getEditableProfile' && $task != 'advancesearch') {
             unset($fields[$i]);
             continue;
         }
         if (in_array($fieldId, $notSelectedFields['ADVANCE_SEARCHABLE']) && $from === '_loadAllFields' && $task === 'advancesearch') {
             unset($fields[$i]);
         }
     }
     $fields = array_values($fields);
     return true;
 }
Пример #2
0
 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;
 }
Пример #3
0
 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;
 }
Пример #4
0
 function edit($fieldId, $tpl = 'edit')
 {
     //XITODO : duplicate call, remove it
     $field = XiptLibJomsocial::getFieldObject($fieldId);
     $fields = XiptLibJomsocial::getFieldObject();
     $categories = XiptHelperProfilefields::getProfileFieldCategories();
     $this->assign('fields', $fields);
     $this->assign('field', $field);
     $this->assignRef('categories', $categories);
     $this->assign('fieldid', $fieldId);
     // Set the titlebar text
     JToolBarHelper::title(XiptText::_('EDIT_FIELD'), 'profilefields');
     $pane =& JPane::getInstance('sliders');
     $this->assignRef('pane', $pane);
     // Add the necessary buttons
     JToolBarHelper::back('Home', 'index.php?option=com_xipt&view=profilefields');
     JToolBarHelper::divider();
     JToolBarHelper::save('save', 'COM_XIPT_SAVE');
     JToolBarHelper::cancel('cancel', 'COM_XIPT_CLOSE');
     parent::display($tpl);
 }