Exemple #1
0
 public static function getListPublishers()
 {
     $models = Publisher::model()->findAll();
     $list = array();
     foreach ($models as $key => $model) {
         $list[$model->id] = $model->name;
     }
     return $list;
 }
 public function afterSave($event)
 {
     if (!$this->Owner->isNewRecord) {
         $newAttrs = $this->Owner->getAttributes();
         $oldAttrs = $this->getOldAttributes();
         $isUpdated = false;
         foreach ($newAttrs as $key => $value) {
             if (!empty($oldAttrs)) {
                 if ($oldAttrs[$key] != $value) {
                     $isUpdated = true;
                 }
             }
         }
         if ($isUpdated) {
             if ($oldAttrs['publisher_id'] != $newAttrs['publisher_id']) {
                 # add a log when dataset publisher is updated
                 $publisher = Publisher::model()->findByPk($oldAttrs['publisher_id']);
                 if ($publisher) {
                     $this->createLog($this->Owner->id, 'Publisher name updated from : ' . $publisher->name);
                 }
             }
             if ($oldAttrs['submitter_id'] != $newAttrs['submitter_id']) {
                 $submitter = User::model()->findByPk($oldAttrs['submitter_id']);
                 if ($submitter) {
                     $this->createLog($this->Owner->id, 'Submitter updated from : ' . $submitter->first_name . ' ' . $submitter->last_name);
                 }
             }
             if ($oldAttrs['image_id'] != $newAttrs['image_id']) {
                 # add a log when dataset image is updated
                 $this->createLog($this->Owner->id, 'Update image');
             }
             if ($oldAttrs['upload_status'] != 'Published' and $newAttrs['upload_status'] == 'Published') {
                 # add a log when dataset is published
                 $this->createLog($this->Owner->id, 'Dataset publish');
             }
             if (preg_replace('/\\s+/', ' ', trim($oldAttrs['description'])) != preg_replace('/\\s+/', ' ', trim($newAttrs['description']))) {
                 $this->createLog($this->Owner->id, 'Description updated from : ' . $oldAttrs['description']);
             }
             if ($oldAttrs['title'] != $newAttrs['title']) {
                 $this->createLog($this->Owner->id, 'Title updated from : ' . $oldAttrs['title']);
             }
             if ($oldAttrs['dataset_size'] != $newAttrs['dataset_size']) {
                 $this->createLog($this->Owner->id, 'Dataset size updated from : ' . $oldAttrs['dataset_size'] . ' bytes');
             }
             if ($oldAttrs['modification_date'] != $newAttrs['modification_date']) {
                 $this->createLog($this->Owner->id, 'Modification date added : ' . $this->Owner->modification_date);
             }
             if ($oldAttrs['fairnuse'] != $newAttrs['fairnuse']) {
                 $this->createLog($this->Owner->id, 'Fair Use date added : ' . $this->Owner->fairnuse);
             }
         }
     } else {
         $this->createLog($this->Owner->id, 'Dataset Created');
     }
 }
 /**
  * Edit a publisher.
  */
 public function actionEdit($id = 0)
 {
     if ($id > 0) {
         $model = Publisher::model()->findByPk($id);
     } else {
         $model = new Publisher();
     }
     if (isset($_POST['Publisher'])) {
         $model->attributes = $_POST['Publisher'];
         if ($model->validate() && $model->save()) {
             Yii::app()->user->setFlash('successmsg', 'The changes have been saved.');
             $this->redirect('/publisher/index');
         } else {
             Yii::app()->user->setFlash('errormsg', 'Error saving the publisher page.');
             $this->render('edit', array('model' => $model, 'id' => $id));
         }
     } else {
         $this->render('edit', array('model' => $model, 'id' => $id));
     }
 }
 public function actionUpdateImage($id, $item_number_flag = '0')
 {
     if ($item_number_flag == '0') {
         $model = $this->loadModel($id);
     } else {
         $model = Item::model()->find('item_number=:item_number', array(':item_number' => $id));
     }
     $price_tiers = PriceTier::model()->getListPriceTierUpdate($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (Yii::app()->user->checkAccess('item.update')) {
         if (isset($_POST['Item'])) {
             $old_price = $model->unit_price;
             $model->attributes = $_POST['Item'];
             //$qty = isset($_POST['Item']['quantity']) ? $_POST['Item']['quantity'] : 0;
             //$model->quantity = $qty;  //A buggy was not noticed every update reset item to zero EM EUY
             $publisher_name = $_POST['Item']['publisher_id'];
             $category_name = $_POST['Item']['category_id'];
             $author_name = $_POST['Item']['author_id'];
             $publisher_id = Publisher::model()->savePublisher($publisher_name);
             if ($publisher_id !== null) {
                 $model->publisher_id = $publisher_id;
             }
             $author_id = Author::model()->saveAuthor($author_name);
             if ($author_id !== null) {
                 $model->author_id = $author_id;
             }
             $category_id = Category::model()->saveCategory($category_name);
             if ($category_id !== null) {
                 $model->category_id = $category_id;
             }
             if ($model->validate()) {
                 $transaction = Yii::app()->db->beginTransaction();
                 try {
                     if ($model->save()) {
                         if (isset($_POST['Item']['count_interval'])) {
                             Item::model()->saveItemCounSchedule($model->id);
                         }
                         ItemPriceTier::model()->saveItemPriceTier($model->id, $price_tiers);
                         // Product Price (retail price) history
                         ItemPrice::model()->saveItemPrice($model->id, $model->unit_price, $old_price);
                         $this->addImages($model);
                         $transaction->commit();
                         Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, 'Item Id : <strong>' . $model->name . '</strong> have been saved successfully!');
                         $this->redirect(array('admin'));
                     }
                 } catch (Exception $e) {
                     $transaction->rollback();
                     //print_r($e);
                     Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_WARNING, 'Oop something wrong : <strong>' . $e);
                 }
             }
         }
     } else {
         //throw new CHttpException(403, 'You are not authorized to perform this action');
         $this->redirect(array('site/ErrorException', 'err_no' => 403));
     }
     $this->render('update_image', array('model' => $model, 'price_tiers' => $price_tiers));
 }
Exemple #5
0
/*echo $form->labelEx($model,'autor_id'); */
?>
        <?php 
/*echo $form->textField($model,'autor_id'); */
?>
        <?php 
/*echo $form->error($model,'autor_id'); */
?>
    </div>-->

    <div class="row">
        <?php 
echo $form->labelEx($model, 'publisher_id');
?>
        <?php 
echo $form->dropDownList($model, 'publisher_id', CHtml::listData(Publisher::model()->findAll(), 'id', 'publisher_name'), array('empty' => 'Выберите издательство'));
?>
        <?php 
echo $form->error($model, 'publisher_id');
?>
    </div>

    <div class="row">
        <?php 
echo $form->labelEx($model, 'rubric_id');
?>
        <?php 
echo $form->dropDownList($model, 'rubric_id', CHtml::listData(Category::model()->findAll(), 'id', 'title'), array('empty' => 'Выберите рубрику'));
?>
        <?php 
echo $form->error($model, 'rubric_id');
<?php

// get publisher credentials for sendgrid
$publisherId = Yii::app()->user->publisherId;
$publisher = Publisher::model()->findByPk($publisherId);
$sendgridUsername = $publisher->sendgridusername;
$sendgridPassword = $publisher->sendgridpassword;
if (strlen($sendgridUsername) > 0 && strlen($sendgridPassword) > 0) {
    $enableSendgridReporting = true;
} else {
    $enableSendgridReporting = false;
}
if ($enableSendgridReporting) {
    $url = 'https://api.sendgrid.com/';
    $params = array('api_user' => $sendgridUsername, 'api_key' => $sendgridPassword, 'start_date' => $startdate, 'end_date' => $enddate, 'aggregate' => '1');
    $request = $url . 'api/stats.get.json';
    // Generate curl request
    $session = curl_init($request);
    // Tell curl to use HTTP POST
    curl_setopt($session, CURLOPT_POST, true);
    // Tell curl that this is the body of the POST
    curl_setopt($session, CURLOPT_POSTFIELDS, $params);
    // Tell curl not to return headers, but do return the response
    curl_setopt($session, CURLOPT_HEADER, false);
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    // obtain response
    $response = curl_exec($session);
    curl_close($session);
    $data = json_decode($response, true);
    $emailOpeningRate = 0;
    $emailCTR = 0;
Exemple #7
0
<!-- BEGIN PAGE HEADER-->
<div class="row">
	<div class="col-md-12">
		<!-- BEGIN PAGE TITLE & BREADCRUMB-->
		<h3 class="page-title">
		Users
		<a href="/user/edit"><button type="button" class="btn btn-primary" style="float:right">Create user</button></a>
		</h3>

		<!-- END PAGE TITLE & BREADCRUMB-->
	</div>

</div>
<!-- END PAGE HEADER-->

<div class="row">
	<div class="col-md-12">
<?php 
$this->widget('TbGridView', array('type' => "striped bordered", 'enableSorting' => TRUE, 'enablePagination' => TRUE, 'summaryText' => "", 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('header' => "Name", 'name' => "name"), array('header' => "Email", 'name' => "email"), array('header' => "Publisher", 'name' => "publisherid", 'value' => '$data->publisher->name', 'filter' => CHtml::listData(Publisher::model()->findAll(), 'id', 'name')), array('header' => "Created", 'name' => "created"), array('header' => "Edit", 'htmlOptions' => array('style' => "text-align:center;"), 'value' => 'CHtml::link("<i class=\\"fa fa-edit\\"></i>", Yii::app()->createUrl("user/edit", array("id" => $data->id)))', 'type' => "raw"))));
?>
	</div>
</div>



<div class="clearfix">
</div>
 public function actionInitPublisher()
 {
     $model = Publisher::model()->find('id=:publisher_id', array(':publisher_id' => (int) $_GET['id']));
     if ($model !== null) {
         echo CJSON::encode(array('id' => $model->id, 'text' => $model->name));
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Publisher the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Publisher::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function getSendgridStats($startdate, $enddate)
 {
     // get publisher credentials for sendgrid
     $publisherId = Yii::app()->user->publisherId;
     $publisher = Publisher::model()->findByPk($publisherId);
     $sendgridUsername = $publisher->sendgridusername;
     $sendgridPassword = $publisher->sendgridpassword;
     $subscriberApiUrl = $publisher->subscriberapiurl;
     $delivered = 0;
     $opens = 0;
     $clicks = 0;
     $bounces = 0;
     $subscribers = 0;
     $emailOpeningRate = 0;
     $emailCTR = 0;
     if (strlen($sendgridUsername) > 0 && strlen($sendgridPassword) > 0) {
         $enableSendgridReporting = true;
     } else {
         $enableSendgridReporting = false;
     }
     if ($enableSendgridReporting) {
         $url = 'https://api.sendgrid.com/';
         $time = new DateTime('now', new DateTimeZone('UTC'));
         // ensure sendgrid enddate is not later than today's date UTC, otherwise api breaks
         if (strtotime(date('Y-m-j', $enddate)) - strtotime($time->format('Y-m-j')) > 0) {
             $sendgridEnddate = $time->format('Y-m-j');
         } else {
             $sendgridEnddate = date('Y-m-j', $enddate);
         }
         $params = array('api_user' => $sendgridUsername, 'api_key' => $sendgridPassword, 'start_date' => date('Y-m-j', $startdate), 'end_date' => $sendgridEnddate, 'aggregate' => '1');
         //print_r($params);
         $request = $url . 'api/stats.get.json';
         // Generate curl request
         $session = curl_init($request);
         // Tell curl to use HTTP POST
         curl_setopt($session, CURLOPT_POST, true);
         // Tell curl that this is the body of the POST
         curl_setopt($session, CURLOPT_POSTFIELDS, $params);
         // Tell curl not to return headers, but do return the response
         curl_setopt($session, CURLOPT_HEADER, false);
         curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
         // obtain response
         $response = curl_exec($session);
         curl_close($session);
         $data = json_decode($response, true);
         // disable sendgrip reporting if API credentials are not valid
         if (array_key_exists('error', $data)) {
             $enableSendgridReporting = false;
             //print_r($data);
         } else {
             $delivered = $data['delivered'];
             $opens = $data['opens'];
             $clicks = $data['clicks'];
             $bounces = $data['bounces'];
             // calculate opening and click-through rates
             if ($delivered == 0) {
                 $emailOpeningRate = 0;
             } else {
                 $emailOpeningRate = round($opens * 100 / $delivered, 2);
             }
             if ($opens == 0) {
                 $emailCTR = 0;
             } else {
                 $emailCTR = round($clicks * 100 / $opens, 2);
             }
         }
         // look up active subscriber count if API url is defined for publisher
         if (strlen($subscriberApiUrl) > 0) {
             // get number of active email subscribers from sharewall api
             $request = $subscriberApiUrl;
             // Generate curl request
             $session = curl_init($request);
             // Tell curl not to return headers, but do return the response
             curl_setopt($session, CURLOPT_HEADER, false);
             curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
             // obtain response
             $response = curl_exec($session);
             curl_close($session);
             $data = json_decode($response, true);
             $subscribers = $data[0]['count'];
         }
     }
     return array('enabled' => $enableSendgridReporting, 'delivered' => $delivered, 'opens' => $opens, 'clicks' => $clicks, 'bounces' => $bounces, 'subscribers' => $subscribers, 'openingRate' => $emailOpeningRate, 'ctr' => $emailCTR);
 }
Exemple #11
0
<h1>Редактировать книги</h1>


<?php 
echo CHtml::link('Расширенный поиск', '#', array('class' => 'search-button'));
?>
<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
/*echo CHtml::dropDownList('publisher', '',
  CHtml::listData(Publisher::model()->findAll(), 'id', 'publisher_name'),
  array('empty' => 'All'));*/
$this->widget('zii.widgets.grid.CGridView', array('id' => 'books-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('title', array('name' => 'publisher.publisher_name', 'filter' => CHtml::dropDownList('Books[publisher_id]', $model->publisher_id, CHtml::listData(Publisher::model()->findAll(), 'id', 'publisher_name'), array('empty' => 'All'))), array('header' => 'Авторы', 'value' => 'Books::extractObjData($data->autor)', 'filter' => CHtml::dropDownList('Books[id]', $model->id, Books::selectObjData(Autor::model()->findAll(), 'book_id', 'autor_name_id'), array('empty' => 'All')), 'type' => 'raw'), array('name' => 'category.title', 'filter' => CHtml::dropDownList('Books[rubric_id]', $model->rubric_id, CHtml::listData(Category::model()->findAll(), 'id', 'title'), array('empty' => 'All'))), array('header' => 'Фото', 'value' => 'Books::photo($data->id)', 'type' => 'raw', 'htmlOptions' => array('width' => '110px', 'text-align' => 'center')), array('class' => 'CButtonColumn', 'template' => '{update}{delete}'))));
?>

<script>
    function slide(count, id, numPhoto){
        $('#icon_'+id+'_'+numPhoto).hide();
        if (numPhoto < count)
            numPhoto++;
        else
            numPhoto = 1;
        $('#icon_'+id+'_'+numPhoto).show();
    }
</script>
 public function savePublisher($publisher_name)
 {
     $publisher_id = null;
     $exists = Publisher::model()->exists('id=:publisher_id', array(':publisher_id' => (int) $publisher_name));
     if (!$exists) {
         $publisher = new Publisher();
         $publisher->name = $publisher_name;
         $publisher->save();
         $publisher_id = $publisher->id;
     }
     return $publisher_id;
 }
Exemple #13
0
					<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
					<img alt="" class="img-circle" />
					<span class="username">
					<?php 
    echo Yii::app()->user->name;
    ?>
 (<?php 
    echo Yii::app()->user->publisherName;
    ?>
) </span>
					<i class="fa fa-angle-down"></i>
					</a>
					<ul class="dropdown-menu">
						<?php 
    if (Yii::app()->user->isAdmin) {
        $publishers = Publisher::model()->findAllByAttributes(array('dashboardactive' => 1));
        $domainCount = count($publishers);
        $view = Yii::app()->request->getQuery('view');
        if ($view == '') {
            $view = 'index';
        }
        foreach ($publishers as $publisher) {
            $domain = $publisher->name;
            if ($publisher->id != Yii::app()->user->publisherId) {
                echo '<li> <a href="/dashboard/index/view/' . $view . '/id/' . $publisher->id . '"><i class="fa fa-newspaper-o"></i> ' . $publisher->name . '&nbsp;&nbsp;&nbsp;&nbsp;</a></li>';
            }
        }
        if ($domainCount > 1) {
            echo '<li class="divider"></li>';
        }
    }
Exemple #14
0
                    <?php 
echo $form->textField($model, 'ftp_site', array('size' => 60, 'maxlength' => 200, 'disabled' => $model->upload_status == 'Published'));
?>
                    <?php 
echo $form->error($model, 'ftp_site');
?>
                </div>
            </div>

            <div class="control-group">
                <?php 
echo $form->labelEx($model, 'publisher', array('class' => 'control-label'));
?>
                <div class="controls">
                    <?php 
echo $form->dropDownList($model, 'publisher_id', MyHtml::listData(Publisher::model()->findAll(), 'id', 'name'));
?>
                    <?php 
echo $form->error($model, 'publisher_id');
?>
                </div>
            </div>

            <div class="control-group">
                <?php 
echo $form->labelEx($model, 'fairnuse', array('class' => 'control-label'));
?>
                <div class="controls">
                <?php 
echo $form->textField($model, 'fairnuse', array('class' => 'date'));
?>
Exemple #15
0
								</div>
							</div>
						</div>


						<div class="form-group <?php 
echo array_key_exists('publisherid', $model->getErrors()) ? ' has-error' : '';
?>
">
							<label class="col-md-3 control-label">Associated publisher</label>
							<div class="col-md-4">

	

								<?php 
echo $form->dropDownList($model, 'publisherid', CHtml::listData(Publisher::model()->findAll(), 'id', 'name'), array('class' => 'form-control'));
?>
							</div>
						</div>


						

						<div class="form-group">
							<label class="col-md-3 control-label">New password</label>
							<div class="col-md-4">
								<div class="input-group">
									<input type="password" name="newpassword1" class="form-control" placeholder="Password">
									<span class="input-group-addon">
									<i class="fa fa-user"></i>
									</span>