当前位置: 首页>>代码示例>>PHP>>正文


PHP FD::fields方法代码示例

本文整理汇总了PHP中FD::fields方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::fields方法的具体用法?PHP FD::fields怎么用?PHP FD::fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FD的用法示例。


在下文中一共展示了FD::fields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: request

 /**
  * Displays the registration request
  *
  * @since   1.3
  * @access  public
  * @param   string
  * @return
  */
 public function request()
 {
     $id = $this->input->getInt('id');
     $table = JTable::getInstance('Module');
     $table->load($id);
     FD::language()->load('mod_easysocial_registration_requester', JPATH_SITE);
     $params = FD::registry($table->params);
     $profileId = $params->get('profile_id');
     // If there's no profile id, then we automatically assign the default profile id
     if (empty($profileId)) {
         $profileModel = FD::model('profiles');
         $defaultProfile = $profileModel->getDefaultProfile();
         $profileId = $defaultProfile->id;
     }
     $fieldsModel = FD::model('fields');
     $options = array('visible' => SOCIAL_PROFILES_VIEW_MINI_REGISTRATION, 'profile_id' => $profileId);
     $fields = $fieldsModel->getCustomFields($options);
     if (!empty($fields)) {
         FD::language()->loadAdmin();
         $fieldsLib = FD::fields();
         $session = JFactory::getSession();
         $registration = FD::table('Registration');
         $registration->load($session->getId());
         $data = $registration->getValues();
         $args = array(&$data, &$registration);
         $fieldsLib->trigger('onRegisterMini', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     }
     $theme = FD::themes();
     $theme->set('params', $params);
     $theme->set('config', FD::config());
     $theme->set('fields', $fields);
     $output = $theme->output('site/registration/dialog.request');
     return $this->ajax->resolve($output);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:42,代码来源:view.ajax.php

示例2: display

 public function display($tpl = null)
 {
     $auth = JRequest::getString('auth');
     // Get the current logged in user's information
     $model = FD::model('Users');
     $id = $model->getUserIdFromAuth($auth);
     $userId = JRequest::getInt('userid');
     // If user id is not passed in, return logged in user
     if (!$userId) {
         $userId = $id;
     }
     // If we still can't find user's details, throw an error
     if (!$userId) {
         $this->set('code', 403);
         $this->set('message', JText::_('Invalid user id provided.'));
         return parent::display();
     }
     $me = FD::user($id);
     $user = FD::user($userId);
     $this->set('id', $userId);
     $this->set('isself', $id == $userId);
     $this->set('isfriend', $user->isFriends($id));
     $this->set('isfollower', $user->isFollowed($id));
     $this->set('username', $user->username);
     $this->set('friend_count', $user->getTotalFriends());
     $this->set('follower_count', $user->getTotalFollowing());
     $this->set('badges', $user->getTotalBadges());
     $this->set('points', $user->getPoints());
     $this->set('avatar_thumb', $user->getAvatar());
     $birthday = $user->getFieldValue('BIRTHDAY');
     if (!empty($birthday)) {
         $this->set('age', $birthday->value->toAge());
     }
     $gender = $user->getFieldValue('GENDER');
     $this->set('gender', !empty($gender) ? $gender->data : 0);
     // Prepare DISPLAY custom fields
     FD::language()->loadAdmin();
     // FD::apps()->loadAllLanguages();
     $steps = FD::model('steps')->getSteps($user->profile_id, SOCIAL_TYPE_PROFILES, SOCIAL_PROFILES_VIEW_DISPLAY);
     $fields = FD::model('fields')->getCustomFields(array('profile_id' => $user->profile_id, 'data' => true, 'dataId' => $user->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_DISPLAY));
     $library = FD::fields();
     $args = array(&$user);
     $library->trigger('onGetValue', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // Get the step mapping first
     $profileSteps = array();
     foreach ($steps as $step) {
         $profileSteps[$step->id] = JText::_($step->title);
     }
     $profileFields = array();
     foreach ($fields as $field) {
         $value = (string) $field->value;
         if (!empty($value)) {
             $data = array('group_id' => $field->step_id, 'group_name' => $profileSteps[$field->step_id], 'field_id' => $field->id, 'field_name' => JText::_($field->title), 'field_value' => (string) $field->value);
             $profileFields[] = $data;
         }
     }
     $this->set('more_info', $profileFields);
     $this->set('code', 200);
     parent::display();
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:60,代码来源:view.json.php

示例3: display

 /**
  * Responsible to display the generic login form.
  *
  * @since	1.0
  * @access	public
  */
 public function display($tpl = null)
 {
     $my = FD::user();
     // If user is already logged in, they should not see this page.
     if ($my->id > 0) {
         return $this->redirect(FRoute::dashboard(array(), false));
     }
     // Add page title
     FD::page()->title(JText::_('COM_EASYSOCIAL_LOGIN_PAGE_TITLE'));
     // Add breadcrumb
     FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_LOGIN_PAGE_BREADCRUMB'));
     // Facebook codes.
     $facebook = FD::oauth('Facebook');
     $config = FD::config();
     $loginMenu = $config->get('general.site.login');
     // Get any callback urls.
     $return = FD::getCallback();
     // If return value is empty, always redirect back to the dashboard
     if (!$return) {
         // Determine if there's a login redirection
         $urlFromCaller = FD::input()->getVar('return', '');
         if ($urlFromCaller) {
             $return = $urlFromCaller;
         } else {
             if ($loginMenu != 'null') {
                 $return = FRoute::getMenuLink($loginMenu);
             } else {
                 $return = FRoute::dashboard(array(), false);
             }
             $return = base64_encode($return);
         }
     } else {
         $return = base64_encode($return);
     }
     if ($config->get('registrations.enabled')) {
         $profileId = $config->get('registrations.mini.profile', 'default');
         if ($profileId === 'default') {
             $profileId = Foundry::model('profiles')->getDefaultProfile()->id;
         }
         $options = array('visible' => SOCIAL_PROFILES_VIEW_MINI_REGISTRATION, 'profile_id' => $profileId);
         $fieldsModel = Foundry::model('fields');
         $fields = $fieldsModel->getCustomFields($options);
         if (!empty($fields)) {
             FD::language()->loadAdmin();
             $fieldsLib = FD::fields();
             $session = JFactory::getSession();
             $registration = FD::table('Registration');
             $registration->load($session->getId());
             $data = $registration->getValues();
             $args = array(&$data, &$registration);
             $fieldsLib->trigger('onRegisterMini', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
             $this->set('fields', $fields);
         }
     }
     $this->set('return', $return);
     $this->set('facebook', $facebook);
     return parent::display('site/login/default');
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:64,代码来源:view.html.php

示例4: verifyFieldsData

 public function verifyFieldsData($keywords, $userId)
 {
     // return variable
     $content = '';
     // get customfields.
     $fieldsLib = FD::fields();
     $fieldModel = FD::model('Fields');
     $fieldsResult = array();
     $options = array();
     $options['data'] = true;
     $options['dataId'] = $userId;
     $options['dataType'] = SOCIAL_TYPE_USER;
     $options['searchable'] = 1;
     //todo: get customfields.
     $fields = $fieldModel->getCustomFields($options);
     if (count($fields) > 0) {
         //foreach( $fields as $item )
         foreach ($fields as $field) {
             $userFieldData = isset($field->data) ? $field->data : '';
             $args = array($userId, $keywords, $userFieldData);
             $f = array(&$field);
             $dataResult = $fieldsLib->trigger('onIndexerSearch', SOCIAL_FIELDS_GROUP_USER, $f, $args);
             if ($dataResult !== false && count($dataResult) > 0) {
                 $fieldsResult[] = $dataResult[0];
             }
         }
         $contentSnapshot = array();
         $totalReturnFields = count($fieldsResult);
         $invalidCnt = 0;
         if ($fieldsResult) {
             // we need to go through each one to see if any of the result returned is a false or not.
             // false mean, the user canot view the fields.
             // this also mean, the user canot view the searched item.
             foreach ($fieldsResult as $fr) {
                 if ($fr == -1) {
                     $invalidCnt++;
                 } else {
                     if (!empty($fr)) {
                         $contentSnapshot[] = $fr;
                     }
                 }
             }
             if ($invalidCnt == $totalReturnFields) {
                 return -1;
             }
         }
         if ($contentSnapshot) {
             $content = implode('<br />', $contentSnapshot);
         }
     }
     return $content;
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:52,代码来源:search.php

示例5: form

 /**
  * Responsible to display the generic login form via ajax
  *
  * @since	1.0
  * @access	public
  */
 public function form($tpl = null)
 {
     $ajax = FD::ajax();
     $my = FD::user();
     // If user is already logged in, they should not see this page.
     if ($my->id > 0) {
         $this->setMessage(JText::_('COM_EASYSOCIAL_LOGIN_ALREADY_LOGGED_IN'), SOCIAL_MSG_ERROR);
         return $ajax->reject($this->getMessage());
     }
     // Facebook codes.
     $facebook = FD::oauth('Facebook');
     // Get any callback urls.
     $return = FD::getCallback();
     // If return value is empty, always redirect back to the dashboard
     if (!$return) {
         $return = FRoute::dashboard(array(), false);
     }
     // Determine if there's a login redirection
     $config = FD::config();
     $loginMenu = $config->get('general.site.login');
     if ($loginMenu != 'null') {
         $return = FD::get('toolbar')->getRedirectionUrl($loginMenu);
     }
     $return = base64_encode($return);
     $this->set('return', $return);
     $this->set('facebook', $facebook);
     if ($config->get('registrations.enabled')) {
         $profileId = $config->get('registrations.mini.profile', 'default');
         if ($profileId === 'default') {
             $profileId = Foundry::model('profiles')->getDefaultProfile()->id;
         }
         $options = array('visible' => SOCIAL_PROFILES_VIEW_MINI_REGISTRATION, 'profile_id' => $profileId);
         $fieldsModel = FD::model('Fields');
         $fields = $fieldsModel->getCustomFields($options);
         if (!empty($fields)) {
             FD::language()->loadAdmin();
             $fieldsLib = FD::fields();
             $session = JFactory::getSession();
             $registration = FD::table('Registration');
             $registration->load($session->getId());
             $data = $registration->getValues();
             $args = array(&$data, &$registration);
             $fieldsLib->trigger('onRegisterMini', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
             $this->set('fields', $fields);
         }
     }
     $contents = parent::display('site/login/dialog.login');
     return $ajax->resolve($contents);
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:55,代码来源:view.ajax.php

示例6: execute

 /**
  * Triggers the cron service
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function execute()
 {
     $config = FD::config();
     // Check if we need a secure phrase.
     $requirePhrase = $config->get('general.cron.secure');
     $storedPhrase = $config->get('general.cron.key');
     $phrase = JRequest::getVar('phrase', '');
     if ($requirePhrase && empty($phrase) || $requirePhrase && $storedPhrase != $phrase) {
         $this->setStatus('failed');
         $this->output(JText::_('COM_EASYSOCIAL_CRONJOB_PASSPHRASE_INVALID'));
         return $this->render();
     }
     // Data to be passed to the triggers.
     $data = array();
     // Array of states
     $states = array();
     // @trigger: fields.onBeforeCronExecute
     // Retrieve custom fields for the current step
     $fieldsModel = FD::model('Fields');
     $customFields = $fieldsModel->getCustomFields(array('appgroup' => SOCIAL_TYPE_USER));
     $fields = FD::fields();
     $fields->trigger('onCronExecute', SOCIAL_TYPE_USER, $customFields, $data);
     // @trigger: apps.onBeforeCronExecute
     $apps = FD::apps();
     $dispatcher = FD::dispatcher();
     $dispatcher->trigger(SOCIAL_TYPE_USER, 'onCronExecute', $data);
     // Load up files in hooks
     $this->hook($states);
     if (!empty($states)) {
         foreach ($states as $state) {
             $this->output($state);
         }
     }
     // Perform maintenance
     $maintenance = FD::get('Maintenance');
     $maintenance->cleanup();
     $this->render();
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:46,代码来源:cron.php

示例7: resolveNamespace

 /**
  * Resolve a given POSIX path.
  *
  * <code>
  * <?php
  * // This would translate to administrator/components/com_easysocial/controllers/fields.php
  * FD::resolve( 'ajax:/admin/controllers/fields/renderSample' );
  *
  * // This would translate to components/com_easysocial/controllers/dashboard.php
  * FD::resolve( 'ajax:/site/controllers/dashboard/someMethod' );
  * ?>
  * </code>
  *
  * @since	1.0
  * @access	public
  * @param	string		The posix path to lookup for.
  * @return	string		The translated path
  */
 public static function resolveNamespace($namespace)
 {
     // Split the paths.
     $parts = explode('/', $namespace);
     $location = $parts[0];
     $config = FD::config();
     // Remove the location from parts.
     array_shift($parts);
     // Get the absolute path of the initial location
     $path = $location == 'admin' ? SOCIAL_ADMIN : SOCIAL_SITE;
     // Get the method to be invoked.
     $method = array_pop($parts);
     if ($location == 'site' || $location == 'admin') {
         // Determine if this is a view or controller.
         if ($parts[0] == 'controllers') {
             $path = $path . '/' . implode('/', $parts) . '.php';
         } else {
             $path = $path . '/' . implode('/', $parts) . '/view.ajax.php';
         }
     }
     if ($location == 'apps') {
         $group = $parts[0];
         $element = $parts[1];
         $type = $parts[2];
         $typeFile = $parts[3];
         // E.g: apps:/user/tasks/views/viewName/functionName
         if ($type == 'views') {
             $path = SOCIAL_APPS . '/' . $group . '/' . $element . '/views/' . $typeFile . '/view.ajax.php';
         }
         // E.g: apps:/user/tasks/controllers/tasks/functionName
         if ($type == 'controllers') {
             // Import dependencies.
             FD::import('admin:/includes/apps/dependencies');
             $path = SOCIAL_APPS . '/' . $group . '/' . $element . '/controllers/' . $typeFile . '.php';
         }
     }
     if ($location == 'fields') {
         // This is the field group. E.g: users , groups etc.
         $group = $parts[0];
         // This is the field element.
         $element = $parts[1];
         $path = SOCIAL_FIELDS . '/' . $group . '/' . $element . '/ajax.php';
     }
     // Get the arguments from the query string if there is any.
     $args = JRequest::getVar('args', '');
     $ajax = FD::ajax();
     // Check that the file exists.
     jimport('joomla.filesystem.file');
     if (!JFile::exists($path)) {
         $ajax->reject(JText::sprintf('The file %1s does not exist.', $namespace));
         return $ajax->send();
     }
     // Include the path.
     include_once $path;
     // We need to know the name of the class before we can instantiate it.
     switch ($location) {
         case 'fields':
             // This is the group
             $group = $parts[0];
             // We know the second segment is always the element.
             $element = $parts[1];
             // Construct parameters
             $config = array('group' => $group, 'element' => $element, 'field' => null, 'inputName' => SOCIAL_FIELDS_PREFIX . '0');
             // Detect if there is an id passed in.
             $id = JRequest::getInt('id', 0);
             // If there is an id, it should also create a copy of the field.
             if ($id) {
                 $field = FD::table('Field');
                 $field->load($id);
                 $step = FD::table('fieldstep');
                 $step->load($field->step_id);
                 $uid = $step->uid;
                 $params = FD::fields()->getFieldConfigValues($field);
                 $config['params'] = $params;
                 $config['uid'] = $uid;
                 $config['field'] = $field;
                 $config['inputName'] = SOCIAL_FIELDS_PREFIX . $field->id;
             }
             // Determine the class name
             $class = 'SocialFields' . ucfirst($group) . ucfirst($element);
             // Let's instantiate the new object now.
             $obj = new $class($config);
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:ajax.php

示例8: getSuggestedFriends

 public function getSuggestedFriends($userId = null, $limit = '0', $countOnly = false)
 {
     $config = FD::config();
     $db = FD::db();
     $sql = $db->sql();
     $user = FD::user($userId);
     $result = array();
     $total = 0;
     // retrieve friends of friends, who isn't your friend yet.
     $query = "select `tfid` as `ffriend_id`, count(`score`) as `score` from (";
     $query .= " select f1.`target_id` as `tfid`, f1.`actor_id` as `score` from (";
     $query .= "\tselect a.`actor_id` as `mfid` from `#__social_friends` as a where a.`target_id` = {$user->id} and a.`state` = " . SOCIAL_FRIENDS_STATE_FRIENDS;
     $query .= "\tunion ";
     $query .= "\tselect a1.`target_id` as `mfid` from #__social_friends as a1 where a1.`actor_id` = {$user->id} and a1.`state` = " . SOCIAL_FRIENDS_STATE_FRIENDS;
     $query .= " ) as fm";
     $query .= "\tinner join #__social_friends as f1 on fm.mfid = f1.actor_id and f1.state = " . SOCIAL_FRIENDS_STATE_FRIENDS;
     $query .= "\twhere f1.target_id not in (\tselect a.actor_id as `mfid` from #__social_friends as a where a.target_id = {$user->id} and a.state != " . SOCIAL_FRIENDS_STATE_REJECTED;
     $query .= "\tunion";
     $query .= "\tselect a1.target_id as `mfid` from #__social_friends as a1 where a1.actor_id = {$user->id} and a1.state != " . SOCIAL_FRIENDS_STATE_REJECTED . ")";
     $query .= "\tand f1.target_id != {$user->id}";
     $query .= " union";
     $query .= " select f2.actor_id as `tfid`, f2.target_id as score from (";
     $query .= "\tselect b.actor_id as `mfid` from #__social_friends as b where b.target_id = {$user->id} and b.state = " . SOCIAL_FRIENDS_STATE_FRIENDS;
     $query .= "\tunion";
     $query .= "\tselect b1.target_id as `mfid` from #__social_friends as b1 where b1.actor_id = {$user->id} and b1.state = " . SOCIAL_FRIENDS_STATE_FRIENDS;
     $query .= " ) as fm2";
     $query .= "\tinner join #__social_friends as f2 on fm2.mfid = f2.target_id and f2.state = " . SOCIAL_FRIENDS_STATE_FRIENDS;
     $query .= "\twhere f2.actor_id not in (\tselect a.actor_id as `mfid` from #__social_friends as a where a.target_id = {$user->id} and a.state != " . SOCIAL_FRIENDS_STATE_REJECTED;
     $query .= "\tunion";
     $query .= "\tselect a1.target_id as `mfid` from #__social_friends as a1 where a1.actor_id = {$user->id} and a1.state != " . SOCIAL_FRIENDS_STATE_REJECTED . ")";
     $query .= "\tand f2.actor_id != {$user->id}";
     $query .= ") as x";
     $query .= " INNER JOIN `#__users` AS uu ON uu.`id` = x.`tfid` AND uu.`block` = '0'";
     if ($config->get('users.blocking.enabled') && !JFactory::getUser()->guest) {
         // user block
         $query .= ' LEFT JOIN ' . $db->nameQuote('#__social_block_users') . ' as bus';
         $query .= ' ON uu.' . $db->nameQuote('id') . ' = bus.' . $db->nameQuote('user_id');
         $query .= ' AND bus.' . $db->nameQuote('target_id') . ' = ' . $db->Quote(JFactory::getUser()->id);
         $query .= ' WHERE bus.' . $db->nameQuote('id') . ' IS NULL';
     }
     $query .= " group by x.tfid";
     $query .= " order by score desc";
     $sql->raw($query);
     // echo $sql;exit;
     if (!empty($limit) && $limit > 0) {
         $this->setState('limit', $limit);
         // Get the limitstart.
         $limitstart = $this->getUserStateFromRequest('limitstart', 0);
         $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
         $this->setState('limitstart', $limitstart);
         // Set the total number of items.
         $this->setTotal($sql->getSQL(), true);
         $total = $this->getTotal();
         // Get the list of users
         $result = $this->getData($sql->getSQL());
     } else {
         $db->setQuery($sql->getSQL());
         $result = $db->loadObjectList();
         $total = count($result);
     }
     $runTrigger = true;
     if ($limit && $total >= $limit) {
         $runTrigger = false;
     }
     // now we trigger custom fields to search users which has the similar
     // data.
     $fieldsLib = FD::fields();
     $fieldModel = FD::model('Fields');
     $fieldsResult = array();
     if ($runTrigger) {
         $fieldSQL = 'select a.*, b.' . $db->nameQuote('type') . ', b.' . $db->nameQuote('element') . ', b.' . $db->nameQuote('group');
         $fieldSQL .= ', c.' . $db->nameQuote('uid') . ' as ' . $db->nameQuote('profile_id');
         $fieldSQL .= ' FROM ' . $db->nameQuote('#__social_fields') . ' as a';
         $fieldSQL .= ' INNER JOIN ' . $db->nameQuote('#__social_apps') . ' as b';
         $fieldSQL .= ' ON a.app_id = b.id';
         $fieldSQL .= ' LEFT JOIN ' . $db->nameQuote('#__social_fields_steps') . ' as c';
         $fieldSQL .= ' ON a.step_id = c.id';
         $fieldSQL .= ' where a.' . $db->nameQuote('friend_suggest') . ' = ' . $db->Quote('1');
         $db->setQuery($fieldSQL);
         $fields = $db->loadObjectList();
         if (count($fields) > 0) {
             foreach ($fields as $item) {
                 $field = FD::table('Field');
                 $field->bind($item);
                 $field->profile_id = $item->profile_id;
                 $field->data = isset($item->data) ? $item->data : '';
                 $userFieldData = $fieldModel->getCustomFieldsValue($field->id, $user->id, SOCIAL_FIELDS_GROUP_USER);
                 $args = array($user, $userFieldData);
                 $f = array(&$field);
                 $dataResult = $fieldsLib->trigger('onFriendSuggestSearch', SOCIAL_FIELDS_GROUP_USER, $f, $args);
                 $fieldsResult = array_merge($fieldsResult, $dataResult);
             }
         }
     }
     $tmpResult = array_merge($result, $fieldsResult);
     //reset $result
     $result = array();
     foreach ($tmpResult as $tmpItem) {
         if (!array_key_exists($tmpItem->ffriend_id, $result)) {
             $result[$tmpItem->ffriend_id] = $tmpItem;
//.........这里部分代码省略.........
开发者ID:ppantilla,项目名称:bbninja,代码行数:101,代码来源:friends.php

示例9: getInfo

 /**
  * Retrieve additional information for a specific user
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return
  */
 public function getInfo()
 {
     // Check for request forgeries
     FD::checkToken();
     $view = $this->getCurrentView();
     $id = $this->input->get('id', 0, 'int');
     $user = FD::user($id);
     if (empty($user) || empty($user->id) || $user->isBlock()) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_USERS_NO_SUCH_USER'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     $my = FD::user();
     $privacy = $my->getPrivacy();
     // @privacy: Let's test if the current viewer is allowed to view this profile.
     if ($my->id != $user->id && !$privacy->validate('profiles.view', $user->id, SOCIAL_TYPE_USER)) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_PRIVACY_NOT_ALLOWED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     FD::language()->loadAdmin();
     $index = JRequest::getInt('index');
     $profile = $user->getProfile();
     $sequence = $profile->getSequenceFromIndex($index, SOCIAL_PROFILES_VIEW_DISPLAY);
     $step = FD::table('FieldStep');
     $state = $step->load(array('uid' => $profile->id, 'type' => SOCIAL_TYPE_PROFILES, 'sequence' => $sequence, 'visible_display' => 1));
     if (!$state) {
         $view->setMessage(JText::sprintf('COM_EASYSOCIAL_PROFILE_USER_NOT_EXIST', $user->getName()), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     $fields = FD::model('Fields')->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $user->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_DISPLAY));
     $fieldsLib = FD::fields();
     if (!empty($fields)) {
         $args = array($user);
         $fieldsLib->trigger('onDisplay', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     }
     return $view->call(__FUNCTION__, $fields);
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:44,代码来源:profile.php

示例10: CreateGroup

 function CreateGroup()
 {
     $app = JFactory::getApplication();
     $log_user = JFactory::getUser($this->plugin->get('user')->id);
     $user = FD::user($log_user->id);
     $config = FD::config();
     //create group post structure
     $grp_data = array();
     $result = new stdClass();
     $valid = 1;
     $title = $app->input->get('title', null, 'STRING');
     $parmalink = $app->input->get('parmalink', null, 'STRING');
     $description = $app->input->get('description', null, 'STRING');
     $type = $app->input->get('type', 0, 'INT');
     $categoryId = $app->input->get('category_id', 0, 'INT');
     $avtar_pth = '';
     $avtar_scr = '';
     $avtar_typ = '';
     $phto_obj = null;
     if (!empty($_FILES['file']['name'])) {
         $upload_obj = new EasySocialApiUploadHelper();
         //ckecking upload cover
         //$phto_obj = $upload_obj->uploadPhoto($log_user->id,'group');
         $phto_obj = $upload_obj->ajax_avatar($_FILES['file']);
         $avtar_pth = $phto_obj['temp_path'];
         $avtar_scr = $phto_obj['temp_uri'];
         $avtar_typ = 'upload';
         $avatar_file_name = $_FILES['file']['name'];
     }
     $cover_data = null;
     if (!empty($_FILES['cover_file']['name'])) {
         $upload_obj = new EasySocialApiUploadHelper();
         //ckecking upload cover
         $cover_data = $upload_obj->ajax_cover($_FILES['cover_file'], 'cover_file');
         //$phtomod	= FD::model( 'Photos' );
         //$cover_obj = $upload_obj->uploadCover($log_user->id,'group');
         //$cover_data = $phtomod->getMeta($cover_obj->id, SOCIAL_PHOTOS_META_PATH);
         //
     }
     //
     //check title
     if (empty($title) || $title == null) {
         $valid = 0;
         $result->status = 0;
         $result->message[] = "Invalid group name";
     }
     //check parmalink
     if (empty($parmalink) || $parmalink == null) {
         $valid = 0;
         $result->status = 0;
         $result->message[] = "Invalid parmalink";
     }
     //check description
     if (empty($description) || $description == null) {
         $valid = 0;
         $result->status = 0;
         $result->message[] = "Empty description not allowed";
     }
     //check group type
     if (empty($type) || $type == 0) {
         $valid = 0;
         $result->status = 0;
         $result->message[] = "Please Add group type";
     }
     if (!$valid) {
         return $result;
     } else {
         // create steps
         $db = FD::db();
         $group = FD::table('Group');
         FD::import('admin:/includes/group/group');
         $group = new SocialGroup();
         // Load front end's language file
         FD::language()->loadSite();
         $category = FD::table('GroupCategory');
         $category->load($categoryId);
         // Get the steps
         $stepsModel = FD::model('Steps');
         $steps = $stepsModel->getSteps($categoryId, SOCIAL_TYPE_CLUSTERS);
         // Get the fields
         $lib = FD::fields();
         $fieldsModel = FD::model('Fields');
         /*$post = $this->input->post->getArray();
         		$args = array(&$post, &$group, &$errors);*/
         // query written due to commented function not working
         $query = "SELECT a.id,a.unique_key\tFROM `#__social_fields` AS `a` \n\t\t\t\t\t\tLEFT JOIN `#__social_apps` AS `b` ON `b`.`id` = `a`.`app_id`\n\t\t\t\t\t\tLEFT JOIN `#__social_fields_steps` AS `d` ON `a`.`step_id` = `d`.`id` \n\t\t\t\t\t\tWHERE `a`.`step_id` = '" . $steps[0]->id . "' ORDER BY `d`.`sequence` ASC,`a`.`ordering` ASC";
         $db->setQuery($query);
         $field_ids = $db->loadAssocList();
         /*foreach ($steps as $step) {
         
         					if ($group->id) {
         						$step->fields 	= $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $group->id, 'dataType' => SOCIAL_TYPE_GROUP));
         					}
         					else {
         						$step->fields 	= $fieldsModel->getCustomFields(array('step_id' => $step->id));
         					}
         
         					
         				}*/
         foreach ($field_ids as $field) {
//.........这里部分代码省略.........
开发者ID:yalive,项目名称:com_api-plugins,代码行数:101,代码来源:group.php

示例11: store

 /**
  * Stores the user object
  *
  * @since	1.0
  * @access	public
  */
 public function store()
 {
     // Check for request forgeries
     FD::checkToken();
     // Load front end's language file
     FD::language()->loadSite();
     // Get the current task
     $task = $this->getTask();
     // Determine if this is an edited user.
     $id = $this->input->get('id', 0, 'int');
     $id = !$id ? null : $id;
     // Get the posted data
     $post = $this->input->getArray('post');
     // this should come from backend user management page only.
     $autoApproval = isset($post['autoapproval']) ? $post['autoapproval'] : 0;
     // Create an options array for custom fields
     $options = array();
     if (!$id) {
         $user = new SocialUser();
         // Get the profile id
         $profileId = $this->input->get('profileId');
     } else {
         // Here we assume that the user record already exists.
         $user = FD::user($id);
         // Get the profile id from the user
         $profileId = $user->getProfile()->id;
         $options['data'] = true;
         $options['dataId'] = $id;
         $options['dataType'] = SOCIAL_TYPE_USER;
     }
     // Set the profile id
     $options['profile_id'] = $profileId;
     // Set the group
     $options['group'] = SOCIAL_FIELDS_GROUP_USER;
     // Load the profile
     $profile = FD::table('Profile');
     $profile->load($profileId);
     // Set the visibility
     // since this is at backend so we assume admin is editing someone else.
     if (!$id) {
         $options['visible'] = SOCIAL_PROFILES_VIEW_REGISTRATION;
     }
     // Get fields model
     $fieldsModel = ES::model('Fields');
     // Get the custom fields
     $fields = $fieldsModel->getCustomFields($options);
     // Initialize default registry
     $registry = ES::registry();
     // Get disallowed keys so we wont get wrong values.
     $disallowed = array(ES::token(), 'option', 'task', 'controller', 'autoapproval');
     // Process $_POST vars
     foreach ($post as $key => $value) {
         if (!in_array($key, $disallowed)) {
             if (is_array($value)) {
                 $value = json_encode($value);
             }
             $registry->set($key, $value);
         }
     }
     // Test to see if the points has changed.
     $points = $this->input->get('points', 0, 'int');
     // Lets get the difference of the points
     $userPoints = $user->getPoints();
     // If there is a difference, the admin may have altered the user points
     if ($userPoints != $points) {
         // Insert a new points record for this new adjustments.
         if ($points > $userPoints) {
             // If the result points is larger, we always need to subtract and get the balance.
             $totalPoints = $points - $userPoints;
         } else {
             // If the result points is smaller, we always need to subtract.
             $totalPoints = -($userPoints - $points);
         }
         $pointsLib = FD::points();
         $pointsLib->assignCustom($user->id, $totalPoints, JText::_('COM_EASYSOCIAL_POINTS_ADJUSTMENTS'));
         $user->points = $points;
     }
     // Convert the values into an array.
     $data = $registry->toArray();
     // Get the fields lib
     $fieldsLib = FD::fields();
     // Build arguments to be passed to the field apps.
     $args = array(&$data, &$user);
     // @trigger onAdminEditValidate
     $errors = $fieldsLib->trigger('onAdminEditValidate', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // If there are errors, we should be exiting here.
     if (is_array($errors) && count($errors) > 0) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_SAVE_ERRORS'), SOCIAL_MSG_ERROR);
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $this->view->call('form', $errors);
     }
     // @trigger onAdminEditBeforeSave
     $errors = $fieldsLib->trigger('onAdminEditBeforeSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:users.php

示例12: edit

 /**
  * Responsible to output the edit profile layout
  *
  * @since	1.0
  * @access	public
  * @param	string	The name of the template file to parse; automatically searches through the template paths.
  * @return	null
  * @author	Mark Lee <mark@stackideas.com>
  */
 public function edit($errors = null)
 {
     // Unauthorized users should not be allowed to access this page.
     FD::requireLogin();
     // Set any messages here.
     FD::info()->set($this->getMessage());
     // Load the language file from the back end.
     FD::language()->loadAdmin();
     // Get list of steps for this user's profile type.
     $profile = $this->my->getProfile();
     // Get user's installed apps
     $appsModel = FD::model('Apps');
     $userApps = $appsModel->getUserApps($this->my->id);
     // Get the steps model
     $stepsModel = FD::model('Steps');
     $steps = $stepsModel->getSteps($profile->id, SOCIAL_TYPE_PROFILES, SOCIAL_PROFILES_VIEW_EDIT);
     // Get custom fields model.
     $fieldsModel = FD::model('Fields');
     // Get custom fields library.
     $fields = FD::fields();
     // Set page title
     FD::page()->title(JText::_('COM_EASYSOCIAL_PAGE_TITLE_ACCOUNT_SETTINGS'));
     // Set the page breadcrumb
     FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_PROFILE'), FRoute::profile());
     FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_ACCOUNT_SETTINGS'));
     // Check if there are any errors in the session
     // If session contains error, means that this is from the FD::fields()->checkCompleteProfile();
     if (empty($errors)) {
         $session = JFactory::getSession();
         $errors = $session->get('easysocial.profile.errors', '', SOCIAL_SESSION_NAMESPACE);
         if (!empty($errors)) {
             FD::info()->set(false, JText::_('COM_EASYSOCIAL_PROFILE_PLEASE_COMPLETE_YOUR_PROFILE'), SOCIAL_MSG_ERROR);
         }
     }
     // Set the callback for the triggered custom fields
     $callback = array($fields->getHandler(), 'getOutput');
     // Get the custom fields for each of the steps.
     foreach ($steps as &$step) {
         $step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $this->my->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => 'edit'));
         // Trigger onEdit for custom fields.
         if (!empty($step->fields)) {
             $post = JRequest::get('post');
             $args = array(&$post, &$this->my, $errors);
             $fields->trigger('onEdit', SOCIAL_FIELDS_GROUP_USER, $step->fields, $args, $callback);
         }
     }
     // Determines if we should show the social tabs on the left.
     $showSocialTabs = false;
     // Determines if the user has associated
     $associatedFacebook = $this->my->isAssociated('facebook');
     $facebookClient = false;
     $facebookMeta = array();
     $fbOAuth = false;
     $fbUserMeta = array();
     if ($associatedFacebook) {
         // We want to show the tabs
         $showSocialTabs = true;
         $facebookToken = $this->my->getOAuthToken('facebook');
         $facebookClient = FD::oauth('facebook');
         // Set the access for the client.
         $facebookClient->setAccess($facebookToken);
         try {
             $fbUserMeta = $facebookClient->getUserMeta();
         } catch (Exception $e) {
             $message = (object) array('message' => JText::sprintf('COM_EASYSOCIAL_OAUTH_FACEBOOK_ERROR_MESSAGE', $e->getMessage()), 'type' => SOCIAL_MSG_ERROR);
             FD::info()->set($message);
         }
         $fbUserMeta = false;
         $fbOAuth = $this->my->getOAuth(SOCIAL_TYPE_FACEBOOK);
         $facebookMeta = FD::registry($fbOAuth->params);
         $facebookPermissions = FD::makeArray($fbOAuth->permissions);
     }
     $this->set('fbUserMeta', $fbUserMeta);
     $this->set('fbOAuth', $fbOAuth);
     $this->set('showSocialTabs', $showSocialTabs);
     $this->set('facebookMeta', $facebookMeta);
     $this->set('facebookClient', $facebookClient);
     $this->set('associatedFacebook', $associatedFacebook);
     $this->set('profile', $profile);
     $this->set('steps', $steps);
     $this->set('apps', $userApps);
     return parent::display('site/profile/default.edit.profile');
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:92,代码来源:view.html.php

示例13: getFieldData

 /**
  * Retrieves the custom field raw data from this user.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function getFieldData($key, $default = '')
 {
     static $processed = array();
     if (!isset($processed[$this->id])) {
         $processed[$this->id] = array();
     }
     if (!isset($processed[$this->id][$key])) {
         if (!isset(SocialUserStorage::$fields[$this->id][$key])) {
             $result = FD::model('Fields')->getCustomFields(array('group' => SOCIAL_TYPE_USER, 'uid' => $this->profile_id, 'data' => true, 'dataId' => $this->id, 'dataType' => SOCIAL_TYPE_USER, 'key' => $key));
             SocialUserStorage::$fields[$this->id][$key] = isset($result[0]) ? $result[0] : false;
         }
         $field = SocialUserStorage::$fields[$this->id][$key];
         // Initialize a default property
         $processed[$this->id][$key] = '';
         if ($field) {
             // Trigger the getFieldValue to obtain data from the field.
             $value = FD::fields()->getData($field);
             $processed[$this->id][$key] = $value;
         }
     }
     return $processed[$this->id][$key];
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:30,代码来源:user.php

示例14: createOAuthUser

 /**
  * Creates a user in the system for users who logged in via oauth
  *
  * Example:
  * <code>
  * <?php
  * $model 	= FD::model( 'Registration' );
  * $model->createUser( $registrationTable );
  *
  * ?>
  * </code>
  *
  * @since	1.0
  * @access	public
  * @param	SocialTableRegistration		The registration object.
  * @return	int		The last sequence for the profile type.
  *
  * @author	Mark Lee <mark@stackideas.com>
  */
 public function createOAuthUser($accessToken, $data, $client, $import = true, $sync = true)
 {
     $config = FD::config();
     // Registrations needs to be enabled.
     if (!$config->get('registrations.enabled')) {
         $this->setError(JText::_('COM_EASYSOCIAL_REGISTRATIONS_DISABLED'));
         return false;
     }
     // Load profile type.
     $profile = FD::table('Profile');
     $profile->load($data['profileId']);
     // Get all published fields apps.
     $fieldsModel = FD::model('Fields');
     $fields = $fieldsModel->getCustomFields(array('profile_id' => $profile->id, 'state' => SOCIAL_STATE_PUBLISHED));
     $args = array(&$data, &$client);
     // Perform field validations here. Validation should only trigger apps that are loaded on the form
     // Get the fields library
     $lib = FD::fields();
     // Get the trigger handler
     $handler = $lib->getHandler();
     // Trigger onRegisterOAuthBeforeSave
     $errors = $lib->trigger('onRegisterOAuthBeforeSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args, array($handler, 'beforeSave'));
     // Get a list of user groups this profile is assigned to
     $json = FD::json();
     $groups = $json->decode($profile->gid);
     // Need to bind the groups under the `gid` column from Joomla.
     $data['gid'] = $groups;
     // Bind the posted data for the user.
     $user = FD::user();
     $user->bind($data, SOCIAL_POSTED_DATA);
     // Detect the profile type's registration type.
     $type = $profile->getRegistrationType(false, true);
     // We need to generate an activation code for the user.
     if ($type == 'verify') {
         $user->activation = FD::getHash(JUserHelper::genRandomPassword());
     }
     // If the registration type requires approval or requires verification, the user account need to be blocked first.
     if ($type == 'approvals' || $type == 'verify') {
         $user->block = 1;
     }
     // Get registration type and set the user's state accordingly.
     $user->set('state', constant('SOCIAL_REGISTER_' . strtoupper($type)));
     // Set the account type.
     $user->set('type', $client->getType());
     // Let's try to save the user now.
     $state = $user->save();
     // If there's a problem saving the user object, set error message.
     if (!$state) {
         $this->setError($user->getError());
         return false;
     }
     // Set the user with proper `profile_id`
     $user->profile_id = $profile->id;
     // Once the user is saved successfully, add them into the profile mapping.
     $profile->addUser($user->id);
     // Assign user object back into the data.
     $data['user'] = $user;
     // Bind custom fields for this user.
     if ($import) {
         $user->bindCustomFields($data);
     }
     // Allow field applications to manipulate custom fields data
     $args = array(&$data, &$client, &$user);
     // Allow fields app to make necessary changes if necessary. At this point, we wouldn't want to allow
     // the field to stop the registration process already.
     // @trigger onRegisterAfterSave
     $lib->trigger('onRegisterOAuthAfterSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // Create a new oauth record on the `#__social_oauth` table so we can simulate the user.
     $oauth = FD::table('OAuth');
     $oauth->uid = $user->id;
     $oauth->type = SOCIAL_TYPE_USER;
     $oauth->client = $client->getType();
     $oauth->oauth_id = $data['oauth_id'];
     $oauth->token = $accessToken->token;
     $oauth->secret = $accessToken->secret;
     $oauth->expires = $accessToken->expires;
     $oauth->pull = $sync;
     $oauth->push = $sync;
     // Store oauth record
     $oauth->store();
     // @TODO: Send notification email to admin
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:registration.php

示例15: createRecurring

 public function createRecurring()
 {
     FD::checkToken();
     $eventId = $this->input->getInt('eventId');
     $schedule = $this->input->getString('datetime');
     $parentEvent = FD::event($eventId);
     $duration = $parentEvent->hasEventEnd() ? $parentEvent->getEventEnd()->toUnix() - $parentEvent->getEventStart()->toUnix() : false;
     $data = $this->input->getVar('postdata');
     // Because this comes form a form, the $data['id'] might be an existing id especially if the create recurring comes from "edit"
     unset($data['id']);
     // Because this comes from a form, $data['applyRecurring'] might be 1 for applying purposes, but for creation, we do not this flag
     unset($data['applyRecurring']);
     // Mark the data as createRecurring
     $data['createRecurring'] = true;
     // Manually change the start end time
     $data['startDatetime'] = FD::date($schedule)->toSql();
     if ($duration) {
         $data['endDatetime'] = FD::date($schedule + $duration)->toSql();
     } else {
         unset($data['endDatetime']);
     }
     $my = FD::user();
     $fieldsLib = FD::fields();
     $options = array();
     $options['uid'] = $parentEvent->category_id;
     $options['group'] = SOCIAL_FIELDS_GROUP_EVENT;
     $fields = FD::model('fields')->getCustomFields($options);
     $event = new SocialEvent();
     $event->category_id = $parentEvent->category_id;
     $event->creator_uid = $parentEvent->creator_uid;
     $event->creator_type = SOCIAL_TYPE_USER;
     $event->state = SOCIAL_STATE_PUBLISHED;
     $event->key = md5(FD::date()->toSql() . $my->password . uniqid());
     $event->parent_id = $parentEvent->id;
     $event->parent_type = SOCIAL_TYPE_EVENT;
     $args = array(&$data, &$event);
     $fieldsLib->trigger('onAdminEditBeforeSave', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args);
     $event->bind($data);
     $event->save();
     // Duplicate nodes from parent
     FD::model('Events')->duplicateGuests($parentEvent->id, $event->id);
     $args = array(&$data, &$event);
     $fieldsLib->trigger('onAdminEditAfterSave', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args);
     $event->bindCustomFields($data);
     $args = array(&$data, &$event);
     $fieldsLib->trigger('onAdminEditAfterSaveFields', SOCIAL_FIELDS_GROUP_EVENT, $fields, $args);
     return $this->view->call(__FUNCTION__);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:48,代码来源:events.php


注:本文中的FD::fields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。