상속: extends Model
예제 #1
0
 /**
  * Run the controller and parse the password template
  *
  * @return Response
  */
 public function run()
 {
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_password');
     if (\Input::post('FORM_SUBMIT') == 'tl_password') {
         $pw = \Input::postUnsafeRaw('password');
         $cnf = \Input::postUnsafeRaw('confirm');
         // The passwords do not match
         if ($pw != $cnf) {
             \Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
         } elseif (Utf8::strlen($pw) < \Config::get('minPasswordLength')) {
             \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], \Config::get('minPasswordLength')));
         } elseif ($pw == $this->User->username) {
             \Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
         } else {
             // Make sure the password has been changed
             if (\Encryption::verify($pw, $this->User->password)) {
                 \Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
             } else {
                 $this->loadDataContainer('tl_user');
                 // Trigger the save_callback
                 if (is_array($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'])) {
                     foreach ($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'] as $callback) {
                         if (is_array($callback)) {
                             $this->import($callback[0]);
                             $pw = $this->{$callback[0]}->{$callback[1]}($pw);
                         } elseif (is_callable($callback)) {
                             $pw = $callback($pw);
                         }
                     }
                 }
                 $objUser = \UserModel::findByPk($this->User->id);
                 $objUser->pwChange = '';
                 $objUser->password = \Encryption::hash($pw);
                 $objUser->save();
                 \Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
                 $this->redirect('contao/main.php');
             }
         }
         $this->reload();
     }
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->messages = \Message::generate();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pw_change'];
     $objTemplate->submitButton = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
     $objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
     $objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];
     return $objTemplate->getResponse();
 }
 /**
  * @param $row
  * @param $label
  * @param DataContainer $dc
  * @param $args
  * @return mixed
  */
 public function labelCallback($row, $label, DataContainer $dc, $args)
 {
     // Set image
     $image = 'protect';
     if (Encryption::decrypt($row['protect']) == '1') {
         $image .= '_';
     }
     $args[0] = sprintf('<div class="list_icon_new" style="background-image:url(\'%s%s/images/%s.gif\')">&nbsp;</div>', TL_SCRIPT_URL, SECURE_ACCESSDATA_PATH, $image);
     // Set User
     if (is_numeric($args[3])) {
         $objUser = UserModel::findByPk($args[3]);
         if ($objUser !== null) {
             $args[3] = $objUser->name;
         }
     }
     switch ($row['type']) {
         case 'weblogin':
             $args[4] = sprintf('%s<br>%s', Encryption::decrypt($row['weblogin_name']), Encryption::decrypt($row['weblogin_pwd']));
             break;
         case 'contao_login':
             $args[4] = sprintf('%s<br>%s', Encryption::decrypt($row['contao_user']), Encryption::decrypt($row['contao_pwd']));
             break;
         case 'encryption_key':
             $strEncryptionKey = Encryption::decrypt($row['encryption_key']);
             if (strlen($strEncryptionKey) <= 32) {
                 $args[4] = $strEncryptionKey;
             } else {
                 $args[4] = substr($strEncryptionKey, 0, 29) . '...';
             }
             break;
         case 'mail':
             $args[4] = sprintf('%s<br>%s<br>%s', Encryption::decrypt($row['mail_email']), Encryption::decrypt($row['mail_loginname']), Encryption::decrypt($row['mail_pwd']));
             break;
         case 'project':
             break;
         case 'online_project':
             break;
     }
     return $args;
 }
    /**
     * Input-field-callback
     * return the html-table with the album-information for restricted users
     * @return string
     */
    public function inputFieldCbGenerateAlbumInformations()
    {
        $objAlb = GalleryCreatorAlbumsModel::findByPk(Input::get('id'));
        $objUser = \Contao\UserModel::findByPk($objAlb->owner);
        $owner = $objUser === null ? 'no-name' : $objUser->name;
        // check User Role
        $this->checkUserRole(Input::get('id'));
        if (false == $this->restrictedUser) {
            $output = '
<div class="album_infos">
<br /><br />
<table cellpadding="0" cellspacing="0" width="100%" summary="">
	<tr class="odd">
		<td style="width:25%"><strong>' . $GLOBALS['TL_LANG']['tl_gallery_creator_albums']['id'][0] . ': </strong></td>
		<td>' . $objAlb->id . '</td>
	</tr>
</table>
</div>
				';
            return $output;
        } else {
            $output = '
<div class="album_infos">
<table cellpadding="0" cellspacing="0" width="100%" summary="">
	<tr class="odd">
		<td style="width:25%"><strong>' . $GLOBALS['TL_LANG']['tl_gallery_creator_albums']['id'][0] . ': </strong></td>
		<td>' . $objAlb->id . '</td>
	</tr>
	<tr>
		<td><strong>' . $GLOBALS['TL_LANG']['tl_gallery_creator_albums']['date'][0] . ': </strong></td>
		<td>' . Date::parse("Y-m-d", $objAlb->date) . '</td>
	</tr>
	<tr class="odd">
		<td><strong>' . $GLOBALS['TL_LANG']['tl_gallery_creator_albums']['owners_name'][0] . ': </strong></td>
		<td>' . $owner . '</td>
	</tr>
	<tr>
		<td><strong>' . $GLOBALS['TL_LANG']['tl_gallery_creator_albums']['name'][0] . ': </strong></td>
		<td>' . $objAlb->name . '</td>
	</tr>

	<tr class="odd">
		<td><strong>' . $GLOBALS['TL_LANG']['tl_gallery_creator_albums']['comment'][0] . ': </strong></td>
		<td>' . $objAlb->comment . '</td>
	</tr>
	<tr>
		<td><strong>' . $GLOBALS['TL_LANG']['tl_gallery_creator_albums']['thumb'][0] . ': </strong></td>
		<td>' . $objAlb->thumb . '</td>
	</tr>
</table>
</div>
		';
            return $output;
        }
    }