コード例 #1
0
 /**
  * Create profiles for orphan users.
  */
 public static function createProfiles()
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('a.id, a.name')->from($db->quoteName('#__users', 'a'))->leftJoin($db->quoteName('#__itpsc_profiles', 'b') . ' ON a.id = b.user_id')->where('b.user_id IS NULL');
     $db->setQuery($query);
     $results = $db->loadAssocList();
     if ($results !== null and count($results) > 0) {
         foreach ($results as $result) {
             $profile = new Socialcommunity\Profile\Profile($db);
             $data = array('user_id' => $result['id'], 'name' => $result['name'], 'alias' => $result['name'], 'active' => Prism\Constants::ACTIVE);
             $profile->bind($data);
             $profile->store();
         }
     }
 }
コード例 #2
0
 private function createProfile($userId, $name)
 {
     $data = array('user_id' => (int) $userId, 'name' => $name, 'alias' => $name, 'active' => Prism\Constants::ACTIVE);
     $profile = new Socialcommunity\Profile\Profile($this->db);
     $profile->bind($data);
     $profile->store();
     $params = JComponentHelper::getParams('com_socialcommunity');
     /** @var $params Joomla\Registry\Registry */
     $filesystemHelper = new Prism\Filesystem\Helper($params);
     // If the filesystem is local, create a user folder.
     if ($filesystemHelper->isLocal()) {
         $mediaFolder = JPath::clean(JPATH_BASE . '/' . $filesystemHelper->getMediaFolder($userId), '/');
         if (!JFolder::exists($mediaFolder)) {
             JFolder::create($mediaFolder);
         }
     }
 }